import { BasicColumn, FormSchema } from '@/components/Table';
import { h, ref } from 'vue';
import { Tag } from 'ant-design-vue';
import { dictAllListApi, supplierListApi, materialListApi } from '@/api/sys/msUser';
import util from '@/utils/util';

import { useMessage } from '@/hooks/web/useMessage';
import { VxeFormItemProps, VxeGridPropTypes } from '@/components/VxeTable';



export const vxeTableColumns: VxeGridPropTypes.Columns = [
  { type: 'radio', width: 60, align: 'center'},
  // {
  //   title: '订单分解编号',
  //   field: 'no',
  //   align: 'center',
  //   filters: [{ data: '' }],
  //   filterRender: {
  //     name: 'VxeInput',
  //   },
  //   width: 140,
  //   showOverflow: 'title',
  // },
  {
    title: '订单标识号',
    field: 'biaoShiHao',
    align: 'center',
    filters: [{ data: '' }],
    filterRender: {
      name: 'VxeInput',
    },
    width: 140,
    showOverflow: 'title',
  },
  {
    title: '型号',
    field: 'model',
    align: 'center',

    // filters: [{ data: '' }],
    // filterRender: {
    //   name: 'VxeInput',
    // },
    showOverflow: 'title',
  },
  {
    title: '规格',
    field: 'guige',
    align: 'center',

    // filters: [{ data: '' }],
    // filterRender: {
    //   name: 'VxeInput',
    // },
    showOverflow: 'title',
  },
  {
    title: '计划投产日',
    field: 'planDate',
    align: 'center',
    sortable: true,
    formatter: ({ cellValue, row, column }) => {
      let val = '';
      if (!cellValue) {
        return val;
      }
      val = cellValue.split(" ")[0];
      return val;
    },
    width: 100,
    showOverflow: 'title',
  },
  {
    title: '订单要求交期',
    field: 'requireDate',
    width: 100,
    align: 'center',
    formatter: ({ cellValue, row, column }) => {
      let val = '';
      if (!cellValue) {
        return val;
      }
      val = cellValue.split(" ")[0];
      return val;
    },
    sortable: true,
    showOverflow: 'title',
  },
  {
    title: '是否关闭',
    field: 'izClose',
    align: 'center',
    slots:{
      default: ({ row }) => {
        let color="";
        let text="";
        if(row.closeId){
          text="已关闭";
          color="red";
        }else{
          text="未关闭";
          color="green";
        }
        return h(Tag, {color}, () => text);

      }
    },
    width: 100,
    showOverflow: 'title',
  },
  {
    title: '是否排产',
    field: 'mainId',
    align: 'center',
    slots: {
      default: ({row}) => {
        let color = "";
        let text = "";
        if (row.mainId) {
          text = "已安排";
          color = "green";
        } else {
          text = "未安排";
          color = "orange";
        }
        return h(Tag, {color}, () => text);

      }
    }
  },
  {
    title: '生产数量',
    field: 'thisNum',
    align: 'center',

    // width: 100,
    showOverflow: 'title',
  },
  {
    title: '计划开始时间',
    field: 'startTime',
    align: 'center',
    sortable: true,
    width: 180,
    showOverflow: 'title',
  },
  {
    title: '计划结束时间',
    field: 'endTime',
    align: 'center',
    sortable: true,
    width: 180,
    showOverflow: 'title',
  },
  {
    width: 90,
    title: '操作',
    align: 'center',
    field: '',
    slots: { default: 'action' },
    fixed: 'right',
  },
];

